//
//  HashrateTeamVC.m
//  WalletAPP
//
//  Created by 罗弟祥 on 2019/10/9.
//  Copyright © 2019 罗弟祥. All rights reserved.
//

#import "HashrateTeamVC.h"
#import "NaviView.h"
#import "HashrateTeamCell.h"
#import "HashrateModel.h"
@interface HashrateTeamVC ()
@property (nonatomic, retain) NaviView *naviView;
@property (nonatomic, retain) RefreshVM *vm;
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation HashrateTeamVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    if (self.index == 0) {
        [self configViewModel];
    }else{
        [self configTeamViewModel];

    }
}


-(void)configViewModel{
    
    __weak __typeof(&*self) ws = self;
    self.vm = [RefreshVM new];
    self.vm.urlStr = @"/api/hashrate";
    self.vm.params = [self configParam];
    self.vm.refreshView = self.tableView;
    [self.vm configRefresh];
    self.vm.dataClass = [HashrateModel class];
    self.vm.dataArray = [NSMutableArray new];
    [self.vm requestHeaderData];
    [self.vm setRequestResultBlock:^(id obj) {
        
    }];
}
-(NSDictionary *)configParam{
    return @{};
}

-(void)configTeamViewModel{
    __weak __typeof(&*self) ws = self;
    self.vm = [RefreshVM new];
    self.vm.urlStr = @"/api/hashrate/myteam";
    self.vm.params = [self configParam];
    self.vm.dataClass = [HashrateModel class];
    self.vm.refreshView = self.tableView;
    self.vm.dataArray = [NSMutableArray new];
    [self.vm requestHeaderData];
    [self.vm setRequestResultBlock:^(id obj) {
        
    }];
}

-(NaviView *)naviView{
    if (!_naviView) {
        _naviView = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([NaviView class]) owner:self options:nil].firstObject;
    }
    return _naviView;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.vm.dataArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return UITableViewAutomaticDimension;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return nil;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    HashrateTeamCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (!cell) {
        cell = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([HashrateTeamCell class]) owner:self options:nil].firstObject;
    }
    
    cell.NumL.text = [NSString stringWithFormat:@"%02ld", indexPath.row + 1];
    if (indexPath.row == 0) {
        cell.bgView.backgroundColor = DEF_0xColor(0x3F4ABC, 1);
    }else if (indexPath.row == 1){
        cell.bgView.backgroundColor = DEF_0xColor(0xBBA376, 1);
    }else if (indexPath.row == 2){
        cell.bgView.backgroundColor = DEF_0xColor(0x5C648E, 1);
    }else{
        cell.bgView.backgroundColor = DEF_0xColor(0xFFFFFF, 1);
    }
    
    [cell loadData:self.vm.dataArray[indexPath.row] indexPath:indexPath];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
